package com.doubao.user.entity;

import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableLogic;
import com.baomidou.mybatisplus.annotation.TableName;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.datatype.jsr310.deser.LocalDateTimeDeserializer;
import com.fasterxml.jackson.datatype.jsr310.ser.LocalDateTimeSerializer;
import lombok.Data;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * 用户实体类
 */
@Data
@TableName("user")
public class User implements Serializable {
    private static final long serialVersionUID = 1L;

    /**
     * 用户ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Long id;

    /**
     * 唯一标识
     */
    private String uuid;

    /**
     * 用户名
     */
    private String username;

    /**
     * 密码
     */
    private String password;

    /**
     * 昵称
     */
    private String nickname;

    /**
     * 头像
     */
    private String avatar;

    /**
     * 手机号
     */
    private String phone;

    /**
     * 邮箱
     */
    private String email;

    /**
     * 角色ID
     */
    private Long roleId;

    /**
     * VIP状态 0:非VIP 1:VIP
     */
    private Integer vipStatus;

    /**
     * 累计使用tokens
     */
    private Long totalTokensUsed;


    /**
     * 用户token余额
     */
    private Integer totalTokensBalance;

    /**
     * 微信unionid
     */
    private String unionid;

    /**
     * 小程序openID
     */
    private String miniappOpenid;

    /**
     * 公众号openID
     */
    private String officialOpenid;

    /**
     * 网页应用openID
     */
    private String webOpenid;

    /**
     * APP应用openID
     */
    private String appOpenid;

    /**
     * 微信国家
     */
    private String wxCountry;
    
    /**
     * 微信省份
     */
    private String wxProvince;
    
    /**
     * 微信城市
     */
    private String wxCity;
    
    /**
     * 微信性别 1:男 2:女 0:未知
     */
    private Integer wxSex;
    
    /**
     * 是否关注公众号 1:是 0:否
     */
    private Integer wxSubscribe;
    
    /**
     * 微信公众号关注时间
     */
    private LocalDateTime wxSubscribeTime;

    /**
     * 注册来源
     */
    private String registerSource;

    /**
     * 最后登录时间
     */
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime lastLoginTime;

    /**
     * 最后登录IP
     */
    private String lastLoginIp;

    /**
     * 登录次数
     */
    private Integer loginCount;

    /**
     * 备注
     */
    private String remark;

    /**
     * 扩展JSON
     */
    private String extJson;

    /**
     * 状态 1:正常 0:禁用
     */
    private Integer status;

    /**
     * 是否删除 1:是 0:否
     */
    @TableLogic
    private Integer deleted;

    /**
     * 创建时间
     */
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime createdAt;

    /**
     * 更新时间
     */
    @JsonSerialize(using = LocalDateTimeSerializer.class)
    @JsonDeserialize(using = LocalDateTimeDeserializer.class)
    private LocalDateTime updatedAt;
}